package LoadUnit
{
	import BasicEngine.Dispatcher;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	public class LoadLine extends Sprite
	{
		public var totalfileNum:TextField;
		
		private var title:TextField;
		private var border:Shape;
		private var clrMask:Shape;
		private var timer:int = 0;
				
		public function LoadLine()
		{
			Init();
		}
		
		public function Dispose():void
		{
			this.removeEventListener(Event.ENTER_FRAME, LoopAnimation);
		}
		
		private function Init():void
		{
			title = new TextField();
			title.text = "Loading...";
			title.textColor = 0x666666;
			title.selectable = false;
			border = new Shape();
			border.graphics.beginFill(0x666666, 1);
			
			totalfileNum = new TextField();

			for (var i:int = 0; i < 8; i++)
			{
				border.graphics.drawRoundRect(i * 14, 18, 12, 7, 2, 2);
			}
			
			clrMask = new Shape();
			clrMask.graphics.beginFill(0xff6600, 1);
			clrMask.graphics.drawRoundRect(1, 0, 10, 5, 2, 2);
			clrMask.y = 19;		
			addChild(title);
			addChild(border);
			addChild(clrMask);
			addChild(totalfileNum);
			totalfileNum.x = 60;
			this.addEventListener(Event.ENTER_FRAME, LoopAnimation);
		}
		
		private function LoopAnimation(e:Event):void
		{
			if (Dispatcher.Clock.SystemTime - timer > 300)
			{
			  clrMask.x += 14;
			  timer = Dispatcher.Clock.SystemTime;
			}
		    
			if (clrMask.x > 7 * 14)
			  clrMask.x = 0;
		}
	}
}